<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改动态页面数据功能')" />
    <th:block th:include="include :: datetimepicker-css" />
    <script type="text/javascript" charset="utf-8" src="/js/plugins/ueditor-1.4.3.3/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="/js/plugins/ueditor-1.4.3.3/_examples/editor_api.js"> </script>
    <!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
    <script type="text/javascript" charset="utf-8" src="/js/plugins/ueditor-1.4.3.3/lang/zh-cn/zh-cn.js"></script>

    <style type="text/css">
        div{
            width:100%;
        }
    </style>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-content-edit" th:object="${zhgsWebContent}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">类型：</label>
                <div class="col-sm-8">
                    <select name="type" class="form-control m-b" th:with="type=${@dict.getType('zhgs_content_type')}" disabled="disabled">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{type}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">标题：</label>
                <div class="col-sm-8">
                    <input name="title" th:field="*{title}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">描述：</label>
                <div class="col-sm-8">
                    <input name="depict" th:field="*{depict}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">内容：</label>
                <div class="col-sm-8">
                    <input name="content" th:field="*{content}" class="form-control" type="text" style="display: none">
                    <script id="editor" type="text/plain" style="width:1024px;height:500px;"></script>
                </div>
            </div>
            <div class="form-group">    
                <!--<label class="col-sm-3 control-label">链接：</label>-->
                <div class="col-sm-8">
                    <input name="url" th:field="*{url}" class="form-control" type="text" style="display: none">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">内容原创时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input name="contentTime" th:value="${#dates.format(zhgsWebContent.contentTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" required="required">
                    </div>
                </div>
            </div>
                    <div style="float:right;width:20%" >
                    <a class="btn btn-primary btn-rounded btn-md" onclick="submitHandler();"><i class="fa fa-search"></i>&nbsp;保存</a>
                <a class="btn btn-warning btn-rounded btn-md"  onclick="window.location.reload()"><i class="fa fa-refresh"></i>&nbsp;&nbsp;&nbsp;重置</a>
                </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script type="text/javascript">
        var prefix = ctx + "webContent/content";
        $("#form-content-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            $("input[name='content']").attr("value",UE.getEditor('editor').getContent());
            $("input[name='url']").attr("value",UE.getEditor('editor').getAllHtml());
            $("select[name='type']").removeAttr("disabled");
            if ($.validate.form()) {
                if($("input[name='id']").val()==""){
                    $.operate.saveModal(prefix + "/add", $('#form-content-edit').serialize());
                }else{
                    $.operate.saveModal(prefix + "/edit", $('#form-content-edit').serialize());
                }
            }
        }

        $("input[name='contentTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
                    $(function () {

                        var html = $("input[name='content']").attr("value");

                        var ue = UE.getEditor('editor');
                        ue.ready(function() {
                            //设置编辑器的内容
                            ue.setContent(html);
                        });

                    })
    </script>

</body>
</html>